﻿using System;
using API.Interfaces;
using Framework.Business;
using Framework.Extensions;
using RealDataReceiver.Business;
using RealDataReceiver.Entities;

namespace RealDataReceiver.Service
{
    public class AlarmReceiverService : RestServiceBase<AlarmReceiverRequest>
    {
        public override object OnPost(AlarmReceiverRequest request)
        {
            var response = new AlarmReceiverResponse();

            try
            {
                var ctx = new ServiceContextBase<AlarmReceiverRequest, AlarmReceiverResponse>(request, response);

                var rawString = RequestContext.GetInputStreamAsString();

                ctx.RawInputString = rawString;

                AlarmReceiveBusiness.AlarmReceiveProcess(ctx);

                response.Result = true;
                response.Succeeded = true;
            }
            catch (Exception e)
            {
                response.CaptureException(e);
            }
            return response;
        }
    }
}
